package com.sskj.mine.http;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.request.GetRequest;
import com.lzy.okgo.request.PostRequest;
import com.sskj.common.base.HttpData;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.util.CommonUtil;
import com.sskj.mine.asset.data.AssetBean;
import com.sskj.mine.asset.data.AssetMainBean;
import com.sskj.mine.asset.data.CoinTypeBean;
import com.sskj.mine.asset.data.ExchangeConfigBean;
import com.sskj.mine.asset.data.ExchangeRecordsBean;
import com.sskj.mine.asset.data.TradeAccountBean;
import com.sskj.mine.bean.ExchangeCoinBean;
import com.sskj.mine.bean.ExchangeUsable;
import com.sskj.mine.bean.FeedBackTypeBean;
import com.sskj.mine.bean.NodeBean;
import com.sskj.mine.bean.TeamBean;

import java.io.File;
import java.util.List;

/**
 * 作者 :吕志豪
 * 简书：https://www.jianshu.com/u/6e525b929aac
 * github：https://github.com/lvzhihao100
 * 描述：
 * 创建时间：2018-10-15 14:08
 */
public class HttpService {




    /**
     * 资产管理 首页
     *
     * @return
     */
    public GetRequest<HttpData<PageBean<AssetBean>>> getAssetMainList(String type) {
        return OkGo.<HttpData<PageBean<AssetBean>>>get(HttpConfig.BASE_URL + HttpConfig.GET_ASSET)
                .params("type",type)
                ;
    }
    /**
     * 资产管理 首页
     *
     * @return
     */
    public GetRequest<HttpData<AssetMainBean>> getAssetMain(String type) {
        return OkGo.<HttpData<AssetMainBean>>get(HttpConfig.BASE_URL + HttpConfig.GET_ASSET)
                .params("type",type)
                ;
    }




    /**
     * 兑换页面
     *
     * @param type 1代币兑usdt 2 usdt兑换代币
     * @return
     */
    public PostRequest<HttpData<ExchangeConfigBean>> getExchangeWallet(String type) {
        return OkGo.<HttpData<ExchangeConfigBean>>post(HttpConfig.BASE_URL + HttpConfig.GET_EXCHANGE_WALLET)
                .params("type", type);
    }


    /**
     * 划转记录
     *
     * @param p    页码，默认1
     * @param size 页条数，默认5
     * @return
     */
    public GetRequest<HttpData<PageBean<ExchangeRecordsBean>>> getCashRecord(String p, String size) {
        return OkGo.<HttpData<PageBean<ExchangeRecordsBean>>>get(HttpConfig.BASE_URL + HttpConfig.GET_EXCHANGE_RECORD)
                .params("page", p)
                .params("size", size);
    }


    /**
     * 发送验证码（注册）
     *
     * @param mobile 手机号
     * @param type   1注册 （2 重置 3 安全验证 4 资金密码设置 5 提币）
     * @return
     */
    public GetRequest<HttpData> sendSms(String mcode,String mobile, String type) {
        return OkGo.<HttpData>get(HttpConfig.BASE_URL + HttpConfig.SEND_SMS)
                .params("mcode", mcode)
                .params("mobile", mobile)
                .params("type", type);
    }

    /**
     * 发送邮件
     *
     * @param email 邮箱号
     * @return
     */
    public PostRequest<HttpData> sendEmail(String email, String type) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.SEND_EMAIL)
                .params("email", email)
                .params("type", type)
                ;
    }




    /**
     * 币充值页面
     *
     * @return
     */
    public GetRequest<HttpData<TradeAccountBean>> withdrawList() {
        return OkGo.<HttpData<TradeAccountBean>>get(HttpConfig.BASE_URL + HttpConfig.WITHDRAW_LIST);
    }






    public PostRequest<HttpData<PageBean<NodeBean>>> getNode(String page, String size) {
        return OkGo.<HttpData<PageBean<NodeBean>>>post(HttpConfig.BASE_URL + HttpConfig.GET_NODE)
                .params("page", page)
                .params("size", size);
    }


    public GetRequest<HttpData<List<CoinTypeBean>>> getAllCoinInfo(boolean isCreate) {
        return OkGo.<HttpData<List<CoinTypeBean>>>get(HttpConfig.BASE_URL + HttpConfig.CURRENCYLIST)
                .params("type",isCreate?"2":"1");

    }

    public PostRequest<HttpData> toggleSms(String key,String code) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.TOGGLE_SMS)
                .params("key", key)
                .params("code", code)
                ;
    }

    public PostRequest<HttpData> uploadHead(String filePath) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.UPLOAD_HEAD)
                .params("avatar", new File(filePath));
    }

    public PostRequest<HttpData> identity(String name,String card_id,String front_img,String back_img) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.IDENTITY)
                .params("name", name)
                .params("card_id", card_id)
                .params("front_img", new File(front_img))
                .params("back_img", new File(back_img))
                ;
    }

    public PostRequest<HttpData> toggleGoogle(String key,String google_code) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.TOGGLE_GOOGLE)
                .params("key", key)
                .params("google_code", google_code)
                ;
    }

    public PostRequest<HttpData> unBindShop() {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.UNBIND_SHOP)
                ;
    }

    public GetRequest<HttpData<List<FeedBackTypeBean>>> getFeedBackType() {
        return OkGo.<HttpData<List<FeedBackTypeBean>>>get(HttpConfig.BASE_URL + HttpConfig.FEED_BACK_TYPE);
    }

    public PostRequest<HttpData> feedBack(String type,String desc,String tel) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.FEED_BACK)
                .params("type",type)
                .params("desc",desc)
                .params("tel",tel)
                ;
    }

    public GetRequest<HttpData<PageBean<TeamBean>>> getTeam(String page,boolean isDirect) {
        return OkGo.<HttpData<PageBean<TeamBean>>>get(HttpConfig.BASE_URL + (isDirect?HttpConfig.TEAM_DIRECT:HttpConfig.TEAM))
                .params("page",page);

    }

    public PostRequest<HttpData<List<ExchangeCoinBean>>> getExchangeCoin(int formWalletType, int toWalletType) {
        return OkGo.<HttpData<List<ExchangeCoinBean>>>post(HttpConfig.BASE_URL + HttpConfig.GET_EXCHANGE_COIN)
                .params("formWalletType", formWalletType)
                .params("toWalletType", toWalletType)
                ;
    }

    public PostRequest<HttpData<ExchangeUsable>> getExchangeUsable(String formWalletType, String id) {
        return OkGo.<HttpData<ExchangeUsable>>post(HttpConfig.BASE_URL + HttpConfig.GET_EXCHANGE_USABLE)
                .params("formWalletType", formWalletType)
                .params("id", id)
                ;
    }

    public PostRequest<HttpData> exchange(String formWalletType,String toWalletType,String rotationNum,String payment_password,String id) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.EXCHANGE)
                .params("formWalletType", formWalletType)
                .params("toWalletType", toWalletType)
                .params("rotationNum", rotationNum)
                .params("payment_password", CommonUtil.getFiveMd5Value(payment_password))
                .params("id", id)
                ;
    }
}